import React from 'react';
import { Button, ButtonProps } from "antd";
import { DeploymentUnitOutlined } from '@ant-design/icons';

import { withModal, mountModal } from "@yaf/pro-ui";
import DataAuth from './DataAuth';

interface DataAuthBtnProps extends ButtonProps {
  roleId: number;
  dataScope: number;
  roleName: string;
  fetchList: () => void;
}

const DataAuthBtn: React.FC<DataAuthBtnProps> = ({ roleId, dataScope, roleName, fetchList, ...restProps }) => {

  return (
    <Button
      size="small"
      type="primary"
      icon={<DeploymentUnitOutlined />}
      onClick={() => {
        const DataAuthModal = withModal(DataAuth);
        mountModal(<DataAuthModal
          modalProps={{ title: `数据授权` }}
          roleId={roleId}
          dataScope={dataScope}
          roleName={roleName}
          fetchList={fetchList}
        />)
      }}
      {...restProps}
    >数据授权</Button>
  )
};

export default DataAuthBtn;
